#include "controller.hpp"

GamingController GamingController::_instance;

GamingController& GamingController::GetInstance(){
    return _instance;
}

void GamingController::Control(SDL_Event &event, Creature &player){
    if (event.type==SDL_KEYDOWN){
        if (event.key.keysym.sym==SDLK_F1){
            Exit();
        }else if(event.key.keysym.sym==SDLK_UP || event.key.keysym.sym==SDLK_k){
            player.MoveWithColliTest(0, -1);
        }else if(event.key.keysym.sym==SDLK_DOWN || event.key.keysym.sym==SDLK_j){
            player.MoveWithColliTest(0, 1);
        }else if(event.key.keysym.sym==SDLK_LEFT || event.key.keysym.sym==SDLK_h){
            player.MoveWithColliTest(-1, 0);
        }else if(event.key.keysym.sym==SDLK_RIGHT || event.key.keysym.sym==SDLK_l){
            player.MoveWithColliTest(1, 0);
        }else if(event.key.keysym.sym==SDLK_y){
            player.MoveWithColliTest(-1, -1);
        }else if(event.key.keysym.sym==SDLK_b){
            player.MoveWithColliTest(-1, 1);
        }else if(event.key.keysym.sym==SDLK_n){
            player.MoveWithColliTest(1, 1);
        }else if(event.key.keysym.sym==SDLK_u){
            player.MoveWithColliTest(1, -1);
        }else if(event.key.keysym.sym==SDLK_SEMICOLON){
            player.Look(player.GetPosition().x, player.GetPosition().y);
        }
    }
}
